<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>css背景</title>
	<style type="text/css">
		/*这是以背景图的方式插入图片*/
		.box{
			width: 320px;
			height: 160px;
			border:5px solid #000;
			background-color: gold;
			background-image: url(../images/bg.jpg);
			font-size: 40px;
			color: gold;	
			margin: 50px;
		}

		/*这时直接插入背景,会占用文档流*/
		.box2{
			width: 320px;
			height: 160px;
			border:5px solid #000;
			background-color: gold;
			font-size: 40px;
			color: green;	
			margin: 50px;
		}

		/*背景图方式repeat的应用*/
		.box3{
			width: 320px;
			height: 160px;
			border:5px solid #000;
			background-color: gold;
			margin: 50px;
			background-image: url(../images/bg.jpg);
			/*background-repeat: repeat-x; 只是横向重复平铺,纵向不变化*/
			/*background-repeat: no-repeat;*/ /*不重复平铺*/

			/*background-position:left bottom; *//*设置背景图的位置,有技巧,需与不重复平铺配合使用*/
			/*background-position: 10px 0;*/ /*使用数值的方法来设置背景图的位置*/
			background-image: url(../images/bg.jpg) -20px -20px gold no-repeat;
		}

		.box4{
			width: 100px;
			height: 100px;
			border: 5px solid #000;
			background-image: url(../images/logo.png);
			background-repeat: no-repeat;
		}
	</style>
</head>
<body>
	<div class="box">背景图片</div>
	<div class="box2"><img src="../images/bg.jpg">背景图片</div>
	<div class="box3"></div>
	<div class="box4"></div>
</body>
</html>